

const ajax = require('ajax.js');

var questionMagicUrl = 'app/magic/read';
var divinationUrlList = 'app/divination/getList';

/**
 * magic 相关
 * 
 */

// 获取列表
function getMagicList(opt) {

  ajax.request({
    url: 'app/magic/getList',
    method:'post',
    data: opt.data || {
      pageNumber: opt.pageNumber,
      userId: opt.userId
    },
    success: opt.success,
    fail: opt.fail
  })
  

  /*
  wx.request({
    url: 'http://local.magic.com/app/magic/getList', //仅为示例，并非真实的接口地址
    data: {
      x: '',
      y: ''
    }, 
    method:'post',
    header: {
      'content-type': 'application/json' // 默认值
    },
    success: function (res) {
      opt.success(res.data.result, res.data);
    }
  })
  */

}

function getDivinationList(opt)
{
  ajax.request({
    url: divinationUrlList,
    method: 'post',
    data: opt.data || {
      pageNumber: opt.pageNumber,
      userId: opt.userId,
      currentThemeId:opt.currentThemeId,
      pageSize:1
    },
    success: opt.success,
    fail: opt.fail
  })
}


// 问魔镜
function questionMagic(opt, magicId) {

  ajax.request({
    url: questionMagicUrl,
    method: 'post',
    data: opt.data || {
      magicId: opt.magicId,
      userId: opt.userId,
      currentThemeId : opt.currentThemeId,
      currentContentId: opt.currentContentId
    },
    success: opt.success
  })

}


module.exports = {
  getMagicList: getMagicList,
  questionMagic: questionMagic,
  getDivinationList: getDivinationList
}